﻿
Namespace storageJobConsumerInternal
    Partial Public MustInherit Class diskslice(Of ATOM_T As atom)
        Protected Overridable Function before_open() As Boolean
            Return True
        End Function

        Protected Overridable Function after_open() As Boolean
            Return True
        End Function

        Protected Overridable Function before_create() As Boolean
            Return True
        End Function

        Protected Overridable Function after_create() As Boolean
            Return True
        End Function

        Protected Overridable Function before_close() As Boolean
            Return True
        End Function

        Protected Overridable Function after_close() As Boolean
            Return True
        End Function

        Protected Overridable Function delete(ByVal atom As ATOM_T) As eventComb
            Return Nothing
        End Function

        Protected Overridable Function retire() As Boolean
            Return True
        End Function

        Protected Overridable Function modify(ByVal atom As ATOM_T,
                                              ByVal buff As bytes) As eventComb
            assert(False)
            Return Nothing
        End Function

        Protected Overridable Function append(ByVal atom As ATOM_T,
                                              ByVal buff As bytes) As eventComb
            assert(False)
            Return Nothing
        End Function

        Protected Overridable Function write(ByVal atom As ATOM_T,
                                             ByVal buff As bytes) As eventComb
            Return Nothing
        End Function

        Protected MustOverride Function read(ByVal atom As ATOM_T,
                                             ByVal result As pointer(Of bytes)) As eventComb

        Protected MustOverride Function sizeof(ByVal atom As ATOM_T) As Int64

        Protected Overridable Function atom_ctor(ByVal start As UInt64,
                                                 ByVal metaStart As UInt64,
                                                 ByVal metaLength As UInt64) As ATOM_T
            Return New atom(start, metaStart, metaLength)
        End Function

        Protected Overridable Sub flush()
        End Sub

        Protected Overridable Function supportedVersion(ByVal v As String) As Boolean
            Return strsame(v, version())
        End Function

        Protected MustOverride Function version() As String
        Protected MustOverride Function meta(ByVal atom As ATOM_T, ByVal buff As bytes) As bytes
        Protected MustOverride Function metaLength(ByVal buff As bytes) As UInt64
    End Class
End Namespace
